package com.dr.cmdb.facade.api;


import com.dr.cmdb.common.model.response.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: cmdb
 * @Package: com.dr.cmdb.facade.api
 * @Description: java类作用描述
 * @Author: duanrui
 * @CreateDate: 2021/4/21 20:12
 * @Version: 1.0
 * <p>
 * Copyright: Copyright (c) 2021
 */
@FeignClient(name = "cmdb-service")
@Api(value = "/api/model", tags = "配置项管理")
@RequestMapping("/api/model")
public interface ModelApi {

    @GetMapping("/list")
    ApiResponse<List<Object>> getList(
            @RequestParam Map<String, Object> searchParams);

    @ApiOperation("添加ci项")
    @PostMapping("/add")
    ApiResponse add(
            @ApiParam(required = true, name = "params", value = "添加参数")
            @RequestBody Map<String, Object> params);


    @ApiOperation("修改ci项")
    @PostMapping("/edit")
    ApiResponse edit(
            @ApiParam(required = true, name = "params", value = "修改参数")
            @RequestBody Map<String, Object> params);


    @ApiOperation("删除ci项")
    @PostMapping("/delete/{code}")
    ApiResponse delete(@ApiParam(required = true, name = "code", value = "ci项id")
                       @PathVariable("code") String code);

    @ApiOperation("导出数据")
    @GetMapping("/export")
    void export(HttpServletResponse response, @ApiParam(required = true, name = "searchParams", value = "查询参数")
    @RequestParam Map<String, Object> searchParams);

    @ApiOperation("导入数据")
    @PostMapping("/import")
    ApiResponse importExcel(@ApiParam(required = true, name = "file", value = "导入文件对象")
                            @RequestParam(name = "file") MultipartFile file,
                            @ApiParam(required = true, name = "tableName", value = "导入表名")
                            @RequestParam(name = "tableName") String tableName
    );


}
